package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Scanner;

public class UpdateUserDemo {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "root"
        );

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名:");
        String username = scanner.nextLine();
        System.out.println("请输入新密码:");
        String password = scanner.nextLine();
        System.out.println("请输入新昵称:");
        String nickname = scanner.nextLine();

        String sql = "UPDATE FROM user" +
                "SET password = '"+password+"' ,nickname = '"+nickname+"' " +
                "WHERE username = '"+username+"'";

        System.out.println(sql);

    }
}
